package com.tfjybj.itoo.exam.provider.service.impl;

import org.apache.dubbo.config.annotation.Reference;;
import com.dmsdbj.itoo.tool.base.service.impl.BaseServicePlusImpl;
import com.dmsdbj.itoo.tool.business.ItooResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.exam.entity.ProfessionEntity;
import com.tfjybj.itoo.exam.model.ProfessionModel;
import com.tfjybj.itoo.exam.provider.dao.ProfessionDao;
import com.tfjybj.itoo.exam.provider.service.ProfessionService;
import com.tfjybj.itoo.teach.FacadeApi.ProfessionApi;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import static com.tfjybj.itoo.exam.provider.until.YearAcquisitionUtil.yearAcquisition;

/**
 * ProfessionService接口实现类
 * ${base}表
 *
 * @author 杨江涛
 * @version 2.0.0
 * @since 2.0.0 2018-11-15 10:35:56
 */
@Service("professionService")
public class ProfessionServiceImpl extends BaseServicePlusImpl<ProfessionDao, ProfessionEntity> implements ProfessionService {
	
	//region 模板生成

    @Resource
    private ProfessionDao professionDao;

    @Reference(check = false)
    private ProfessionApi professionApi;

	 @Override
    public PageInfo<ProfessionEntity> queryByLikeName(String name, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(professionDao.queryLikeName(name));
    }

    //endregion

    /* **********************************以下为非模板生成的内容********************************* */

    @Override
    public ItooResult findByAcademyId(String academyId) {
        return professionApi.findByAcademyId(academyId);
    }

    @Override
    public List<ProfessionModel> inquirySpecialty(String academyId) {
        return professionDao.inquirySpecialty(academyId, yearAcquisition().get("minSession"), yearAcquisition().get("maxSession"));
    }

}
